package leetcode.medium.maxancestordiff;

import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import util.adt.TreeNode;

public class SolutionTest {
    private static Solution solution;

    @BeforeClass
    public static void setup() {
        solution = new Solution();
    }

    @AfterClass
    public static void tearUp() {
        solution = null;
    }

    @Test
    public void test1() {
        TreeNode root = new TreeNode(1,
                null,
                new TreeNode(2,
                        null,
                        new TreeNode(0,
                                new TreeNode(3),
                                null)));
        Assert.assertEquals(3, solution.maxAncestorDiff(root));
    }

    @Test
    public void test2() {
        TreeNode root = new TreeNode(
                8,
                new TreeNode(
                        3,
                        new TreeNode(
                                1
                        ),
                        new TreeNode(
                                6,
                                new TreeNode(4),
                                new TreeNode(7)
                        )
                ),
                new TreeNode(
                        10,
                        null,
                        new TreeNode(
                                14,
                                new TreeNode(13),
                                null
                        )
                )
        );
        System.out.println(solution.maxAncestorDiff(root));
        Assert.assertEquals(7, solution.maxAncestorDiff(root));
    }

    @Test
    public void test3() {
        TreeNode root = new TreeNode(
                1,
                new TreeNode(0),
                new TreeNode(8)
        );
        Assert.assertEquals(7, solution.maxAncestorDiff(root));
    }
}
